<template>
	<view class="switch-with-text" :style="{justifyContent:switchValue ? 'flex-start' : 'flex-end'}">
		<view class="switch-container">
			<u-switch v-model="switchValue" @change="handleSwitchChange" :disabled="disabled"  size="26"></u-switch>
		</view>
		<view class="switch-text" :style="{paddingRight:switchValue ? 0 : '5px',paddingLeft:switchValue ? '5px' : 0,color:switchValue?'#ffffff':'rgb(64, 158, 255)'}">
			{{switchValue? trueText : falseText}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				switchValue: false
			};
		},
		props: {
			trueText: {
				type: String,
				default: '开'
			},
			falseText: {
				type: String,
				default: '关'
			},
			disabled:{
				type: String,
				default: false
			}
		},
		methods: {
			handleSwitchChange(newValue) {
				this.switchValue = newValue;
				this.$emit('change', newValue);
			},
			changeStatus(bol) {
				this.switchValue = bol;
			}
		}
	};
</script>

<style scoped lang="scss">
	.switch-with-text {
		display: flex;
		align-items: center;
		position: relative;
		justify-content: flex-end;

		.switch-container {}

		.switch-text {
			position: absolute;
			font-size: 12px;
			padding-right: 5px;
		}
	}
</style>